<%@page import="com.njxzc.igo.model.ShoppingCart"%>
<%@ page language="java" isELIgnored="false"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
	import="java.util.*"%>
<%@  page import="java.util.Map"%>
<%@  page import="java.util.HashMap"%>
<%@  taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="my" uri="/mytag"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">

<link href="AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet"
	type="text/css" />
<link href="AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet"
	type="text/css" />
<link href="basic/css/demo.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/site-nav.css">
<link rel="stylesheet" href="css/cart.css">

<title>cart</title>
<style>
#empty {
	padding: 88px 0 100px 156px;
	background: url(img/T1TvXUXnNjXXXXXXXX-100-100.png) no-repeat 40px 86px;
	position: relative;
}
</style>
<script src="js/basevalue.js"></script>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/cookie_util.js"></script>
<script type="text/javascript" src="AmazeUI-2.4.2/assets/js/amazeui.js"></script>
<script type="text/javascript" src="js/shoppingcart2.js"></script>
<script type="text/javascript" src="js/choosecheckbox.js"></script>
<script type="text/javascript">
    	$(function(){

    		
    		$(".deleteAll").click(function(){
    			if($(":checkbox[name='checked'][checked='checked']").length==0){
    				alert("请选择要删除的宝贝");
    				return ;
    			}else{
    				var isconfirm = confirm("是否删除所有选中的宝贝");
    				if(isconfirm){
    					var checkItem = $(":checkbox[name='checked'][checked='checked']");
        				var itemids = new Array();
        				$.each(checkItem, function(i, n){
        					 itemids[i] = n.value;
        				});
        				//var jsonstr = JSON.stringify(itemids);
        				//把数组变成字符串之后传的更麻烦
    				$.ajax({
    					url : base_path +"/deleteBatch.do",
    					type : "post",
    					data : {
    						"shopids" : itemids
    					},
    					dataType:"json",
    					success:function(){
    						//window.reload();
    						location.reload();
    					},
    					error:function(){
    						alert("删除失败请稍后重试");
    					}
    				})				
    				}
    			}
    		});
    		
    		
    		$("#J_Go").click(function(){
    			var $checkItem = $(":checkbox[name='checked'][checked='checked']");
    			if($checkItem.length==0){
    				alert("没有选中宝贝无法结算");
    				return false;
    			}
    			var shoppingids = new Array();
    			var productids = new Array();
    			for(var i=0;i<$checkItem.length;i++){
    				
    				shoppingids.push($checkItem.eq(i).val());
    				var productId = $checkItem.eq(i).next().text();
    				productids.push(productId);	    				
    			}
				$.ajax({
					url : base_path +"/generateOrder.do",
					type : "post",
					data : {
						"sids" : shoppingids,
						"productids"  : productids
					},
					dataType:"json",
					success:function(data){
						console.log("go");
						window.location.href=base_path+"/pay.jsp";
					},
					error:function(){
						alert("服务器繁忙请重试");
					}
				})	;
    		});
    		
    	})
    </script>
</head>
<body>
	<!--顶栏-->
	<div class="site-nav">
		<div class="sn-bg"></div>
		<div class="sn-con">
			<p class="sn-home">
				<i class="am-icon-home"></i> <a href="index.jsp">爱购首页</a>
			</p>
			<p class="sn-login-info">
				<c:if test="${ empty sessionScope.u.nickname }" var="login">
					<span>汪, 欢迎来到爱购 </span>
					<span> &nbsp;<a href="login.jsp">请登录</a>
					</span>
					<span class="sn-logout-info"> <a href="regist.jsp">免费注册</a>
					</span>
				</c:if>
				<c:if test="${!login }">
					<span>Hi, <a href="">${sessionScope.u.nickname }</a>
					</span>
					<span> <i class="am-icon-comments"></i>&nbsp;消息<a href="">3</a>
					</span>
					<span class="sn-logout-info"> <a href="user/logout.do">退出</a>
					</span>
				</c:if>
			</p>
			<ul class="sn-quick-menu">
				<li class="myiGo"><i class="am-icon-user"></i> <a
					href="myorders.do">我的爱购</a></li>
				<li class="sn-mybrand"><i class="am-icon-heart"></i> <a href="">我关注的品牌</a>
				</li>
				<li class="sn-cart"><i class="am-icon-shopping-cart"></i> <a
					href="myshoppingCart.do">购物车</a> <c:set
						property="${sessionScope.map3 }" var="shoppingcart"></c:set> <span
					name="count"> <my:pt value="${sessionScope.map3 }" />
				</span> 件</li>
			</ul>
		</div>
	</div>

	<!--标题&搜索-->
	<div class="header">
		<div class="header-con">
			<h1 class="iGologo">
				<a href="">爱购iGo.com</a>
			</h1>
			<div class="search" name="search">
				<form action="searchkey.do" method="get">
					<input type="text" placeholder="潮女冬季必备" name="key"
						class="search-inp">
					<!-- 这里提供查询的类名 按名字搜索了 -->
					<input style="display: none" type="text" name="search_kind"
						value="name" class="search-inp">
					<button type="submit" class="search-btn">搜索</button>
				</form>
			</div>
		</div>
	</div>
	<hr data-am-widget="divider" style=""
		class="clear-float-both am-divider am-divider-default" />
	<!--购物车 -->


	<!-- ${item.key} > ${item.value} <br> -->
	<c:if test="${empty sessionScope.map3}">
		<div id="empty">
			<h2>您的购物车还是空的，赶紧行动吧！您可以：</h2>
			<ul>
				<li>看看 <a href="//shoucang.taobao.com/shop_collect_list.htm"
					target="_blank">我的收藏夹</a></li>
				<li>看看 <a
					href="//trade.taobao.com/trade/itemlist/list_bought_items.htm?spm=a1z0d.6639537.0.0.xBKRSx"
					target="_blank" data-spm-anchor-id="a1z0d.6639537.0.0">已买到的宝贝</a></li>
			</ul>
		</div>
	</c:if>
	<div class="concent">
		<div id="cartTable">
			<c:forEach var="item" items="${sessionScope.map3}"
				varStatus="istatus">
				<c:if test="${istatus.first }">
					<div class="cart-table-th">
						<div class="wp">
							<div class="th th-chk">
								<div id="J_SelectAll1" class="select-all J_SelectAll"></div>
							</div>
							<div class="th th-item">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-op">
								<div class="td-inner">操作</div>
							</div>
						</div>
					</div>
					<div class="clear"></div>
				</c:if>
				<div class="item-list">
					<div class="bundle  bundle-last ">
						<div class="bundle-hd">
							<div class="bd-promos">
								<div class="act-promo">店铺：</div>
								<div class="bd-has-promo">
									<a href="#" target="_blank">${item.key } <span class="gt">&gt;&gt;</span></a>&nbsp;&nbsp;
								</div>
								<span class="list-change theme-login">编辑</span>
							</div>
						</div>
						<div class="clear"></div>
						<div class="bundle-main">


							<c:forEach items="${item.value }" var="each">
								<ul class="item-content clearfix">
									<li class="td td-chk">
										<div class="cart-checkbox ">
											<input name="checked" class="check" id="J_CheckBox"
												name="items[]" type="checkbox"
												value="${each.shoppingCartId}">
											<div class="productId" style="display: none">${each.productExample.productId }</div>
										</div>
									</li>
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" target="_blank"
												data-title="${each.productExample.productName }"> <img
												src="uploads/${each.productExample.productImgAdd }"
												width="80px" height="80px" class="itempic J_ItemImg"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" target="_blank"
													title="${each.productExample.productName }"
													class="item-title J_MakePoint">${each.productExample.productName }</a>
											</div>
										</div>
									</li>
									<li class="td td-info">
										<!-- 这里原来写的是商品的型号 这里以后在做 -->
										<div class="item-props item-props-can">
											<!-- 
											<span class="sku-line">颜色分类：111粉色CREOLE PINK</span>
											<span class="sku-line">尺码：170/88A/L</span>
										 -->
											<span class="sku-line">${each.productExample.desciption }</span>
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<!-- 原来价格
												<div class="price-line">
													<em class="price-original">1799.00</em>
												</div>
												 -->
												<div class="price-line">
													<em class="J_Price price-now" tabindex="0">${each.productExample.price }</em>
												</div>
											</div>
										</div>
									</li>
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<div class="sl">
													<input class="min am-btn" name="" id="min01" type="button"
														value="-" /> <input readonly="readonly" class="text_box"
														name="orderamount" type="text" value="${each.amount }"
														style="width: 30px;" /> <input class="add am-btn" name=""
														id="max01" type="button" value="+" />
												</div>
											</div>
										</div>
									</li>
									<li class="td td-sum">
										<div class="td-inner">
											<em tabindex="0" class="J_ItemSum number">${each.amount*each.productExample.price }</em>
										</div>
									</li>
									<li class="td td-op">
										<div class="td-inner">
											<a title="移入收藏夹" class="btn-fav" href="#"> 移入收藏夹</a> <a
												href="javascript:void(0);" data-point-url="#" class="delete">
												删除</a>
										</div>
									</li>
								</ul>
							</c:forEach>
						</div>
					</div>
				</div>

				<c:if test="${istatus.last }">
					<div class="float-bar-wrapper">
						<div id="J_SelectAll2" class="select-all J_SelectAll">
							<div class="cart-checkbox">
								<input class="check-all" id="J_SelectAllCb" name="select-all"
									value="true" type="checkbox"> <label
									for="J_SelectAllCbx2"></label>
							</div>
							<span>全选</span>
						</div>
						<div class="operations">
							<a href="javascript:void(0);" hidefocus="true" class="deleteAll">删除</a>
							<a href="#" hidefocus="true" class="J_BatchFav">移入收藏夹</a>
						</div>
						<div class="float-bar-right">
							<div class="amount-sum">
								<span class="txt">已选商品</span> <em id="J_SelectedItemsCount">0</em><span
									class="txt">件</span>
								<div class="arrow-box">
									<span class="selected-items-arrow"></span> <span class="arrow"></span>
								</div>
							</div>
							<div class="price-sum">
								<span class="txt">合计:</span> <strong class="price">￥<em
									id="J_Total">0.00</em></strong>
							</div>
							<div class="btn-area">
								<a href="javascript:void(0);" id="J_Go"
									class="submit-btn submit-btn-disabled"
									aria-label="请注意如果没有选择宝贝，将无法结算"> <span>结&nbsp;算</span></a>
							</div>
						</div>
					</div>
				</c:if>
			</c:forEach>
		</div>
	</div>

	<div class="footer">
		<div class="footer-hd">
			<p>
				<a href="#">爱购科技</a> <b>|</b> <a href="index.jsp">商城首页</a> <b>|</b>
				<a href="#">支付宝</a> <b>|</b> <a href="#">物流</a>
			</p>
		</div>
		<div class="footer-bd">
			<p>
				<a href="#">关于爱购</a> <a href="#">合作伙伴</a> <a href="#">联系我们</a> <a
					href="#">网站地图</a> <em>(c) 2016-2026 iGo.com 版权所有</em>
			</p>
		</div>
	</div>

	</div>

</body>
</html>